<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<style type="text/css">
	.spanClass{color:#ff0000;font-weight:bold;padding-left:2px;padding-right:2px;}
	.menuitem {color:#707070;background-color:#fffccf;border:#83a3ff solid 1px;POSITION: absolute; VISIBILITY: hidden;width:145px;}
	</style>
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/style.css">
	<script src="<%=basePath %>/js/checkbox1.js" type="text/javascript"></script>
		<script type="text/javascript">
			function goselfpage(c,act,size)
			{
				var count = c;
				var selfnum=document.getElementById('selfpage').value;
				if(checkInt(selfnum) && 0<selfnum && selfnum<=count){
					window.location.href=act+"num="+selfnum+"&size="+size;
					return true;
				}else{
					alert("请输入1-"+count+"之间的整数");
					return false;
				}
				
			}
			function gopagesize(act)
			{
				var selfnum=document.getElementById('pageSize').value;
				if(checkInt(selfnum) && 0<selfnum && selfnum<=100){
					window.location.href=act+"size="+selfnum;
					return true;
				}else {
					alert("请输入1-100之间的整数");
					return false;
				}
			}
			
			function checkInt(num)
			{ 
				return (num%1==0?true:false); 
			} 
			
			function setPage(pnum,psize){
				var urls="<%=basePath %><%=request.getParameter("url4page")%><%=request.getParameter("url4page").indexOf("?")>0?"&":"?"%>num="+pnum+"&size="+psize;
				document.pageform.action=urls;
				document.pageform.submit();
			}
		</script>
	</head>
	<form action="" method="post" name="pageform">
	
	<table width="100%" align="center" bgcolor="#dbecfe" style="color:#7e807e;font-weight:bold">
	<tr>
		<td width="15"></td>
		<td>
		  <s:if test="%{page.rowCount > 0}">
			<s:if test="%{page.num != 1}">
			    <a href="javascript:setPage('${page.first}','${page.size}');">首页</a>&nbsp;
				<a href="javascript:setPage('${page.prev}','${page.size}');">上一页</a>&nbsp; 
			</s:if>
            <s:else></s:else>
            <s:bean name="org.apache.struts2.util.Counter" id="counter">
              <s:param name="first" value="%{page.start}" />
              <s:param name="last" value="%{page.end}" />             
              <s:iterator>                          
                <s:if test="%{page.num != (#counter.current-1)}">
					<a href="javascript:setPage('<s:property/>','${page.size}');"><b>[<s:property/>]</b></a>&nbsp;
			    </s:if>
				<s:else>
				    <span class="spanClass"><s:property/></span>&nbsp;
				</s:else>			
              </s:iterator>
            </s:bean>                   
			<s:if test="%{page.num != page.count}">
				<a href="javascript:setPage('${page.next}','${page.size}');">下一页</a>&nbsp;
				<a href="javascript:setPage('${page.last}','${page.size}');">末页</a>&nbsp;
			</s:if>
			<s:else></s:else>
		  </s:if>
		  <s:else>当前没有任何数据</s:else>
			
		  &nbsp;&nbsp;&nbsp;&nbsp; 共<span class="spanClass">${page.count}</span>页, 共<span class="spanClass">${page.rowCount}</span>条记录
		  <s:if test="%{page.count > 1}">
			&nbsp;&nbsp;输入页数<input id="selfpage" type="text" size="1"/>&nbsp;<input type="button" class="input_link"  value="跳转" onclick="javascript:goselfpage(${page.count},'<%=basePath %>${param.url4page}<%=request.getParameter("url4page").indexOf("?")>0?"&":"?"%>','${page.size}');" />&nbsp;&nbsp;
		  </s:if>
		</td>
	</tr>
	</table>
	</form>
</html>
